//创建主页的控制器JS
msqbapp.controller('indexController',function ($scope,msqbService) {
    //保存父分类ID的变量
    $scope.classifyParentId =0;
    //当前分类ID
    $scope.classifyId  = 1;
    $scope.userId= 0;
    //创建主页的初始化函数
    $scope.indexInit = function () {
        //得到用户ID
        $scope.userId = window.location.search.split('=')[1];
            //根据用户ID得到用户对象
        msqbService.findOne($scope.userId).success(function (resp) {
            $scope.userBean = resp;
        });
        //得到一级分类列表
        msqbService.classifyOneList($scope.classifyParentId).success(function (resp) {
            $scope.classifyList = resp;
        });
        //得到热推题目列表
        msqbService.getMostTopic($scope.classifyId).success(function (resp) {
            if (resp.total>0){
                $scope.mostTopicList = resp.rows;
            }else{
                $scope.mostTopicList = [];
            }
        });

        //得到技术分类列表
        msqbService.classifyOneList($scope.classifyId).success(function (resp) {
        });
    };
    //一级分类标签的点击事件
    $scope.getClassify = function (classifyId) {
        $scope.classifyId = classifyId;
    };
    //热推
    $scope.getTopicItem=function (userId,topicId) {
        window.open("topicitem.html?userId="+userId+"&topicId="+topicId);
    }
});
